<template>
<a-layout>
    <a-layout-header>
        <div class="a-layout-header-img">
            <img src="@/assets/顶部-中信建投LOGO.png">&#12288;
            <img src="@/assets/顶部-分割线.png">&#12288;
            <strong style="font-size:17px">大类资产配置平台</strong>　
            <span v-show='khd'>欢迎&nbsp;{{accountName}}&nbsp;
                <img src="@/assets/顶部-分割线.png">&nbsp;
                <a href="javascript:" @click="goBack">退出</a>
            </span>
            <!-- 　 -->
            <!-- <a-dropdown>
               <span style="font-size:15px" ><font style="color:white">
                 <a class="ant-dropdown-link" href="#">{{accountName}}</a></font></span><a-icon type="down" />
                 <span style="font-size:15px" ><font style="color:white">
                   <a class="ant-dropdown-link" href="#">{{accountName}}<a-icon type="down" /></a></font></span>
                 <a-menu slot="overlay" @click="onClick">
                   <a-menu-item key="1">1st menu item</a-menu-item>
                   <a-menu-item key="2">2nd menu item</a-menu-item>
                   <a-menu-item key="3">3rd menu item</a-menu-item>
                 </a-menu>
               </a-dropdown> -->
        </div>

        <!-- <a-dropdown>
                        <a class="ant-dropdown-link" href="#"><font color="white"> <span style="font-size:15px">linyawei</span> <a-icon type="down" /></font> </a>
                        <a-menu slot="overlay" @click="onClick">
                          <a-menu-item key="1">1st menu item</a-menu-item>
                          <a-menu-item key="2">2nd menu item</a-menu-item>
                          <a-menu-item key="3">3rd menu item</a-menu-item>
                        </a-menu>
                      </a-dropdown> -->

    </a-layout-header>
    <a-layout-content>

        <div class="a-layout-content-div">
            <a-tabs v-model="activeKey" size="small" :tabBarGutter=10 type="card" @change="handleClick">
                <a-tab-pane v-for="(item,index) in atableTabs" :key="item.menuName" :tab="item.menuName">
                </a-tab-pane>
            </a-tabs>
        </div>
    </a-layout-content>

    <a-layout-footer>
        <keep-alive include="AssetAllocation,FOFbuild">
            <router-view></router-view>
        </keep-alive>
    </a-layout-footer>
</a-layout>
</template>

<script>
import '@/style/home.css'
export default {
    data() {
        return {
            accountName: '',
            atableTabs: [],
            activeKey: "",
            khd: true,
            // url: {
            //   AssetAllocation : "/views/asset-allocation/AssetAllocation",
            //   FOFbuild : "/views/asset-allocation/FOFbuild",
            //   MacroData : "/views/asset-allocation/MacroData",
            //   ResearchReport : "/views/asset-allocation/ResearchReport",
            // },
        };
    },
    created() {
        var that = this
        let client;

        // if (localStorage.getItem('0001')) {
        //     // JSON.parse(client.replace(/\'/g,'"' ))
        //     client = JSON.parse(client.replace(/\'/g, '"'))
        //     //设置菜单权限
        //     let parmas = {
        //         id: Number(client.userId),
        //         // id: 2
        //     }
        // }

        // if (localStorage.getItem('token')) {
          // console.log(client.token)
        if (localStorage.getItem('0001')) {
        
          client=localStorage.getItem('0001')
           client = JSON.parse(client.replace(/\'/g, '"'))
           
            //设置菜单权限
            let parmas = {
                id: Number(client.userId),
                // id: 2
            }
            this.khd = false
            this.$http.post(this.$url.clientLoginUrl, parmas).then(res => {
                res.data.profession.map(item => {
                    if (item.sysName == "资产配置系统") {
                        sessionStorage.setItem('flag', 1)
                        // sessionStorage.setItem('token', res.token)
                        // sessionStorage.setItem('tabArray', JSON.stringify(item))
                        this.accountName = item.users.userName
                        sessionStorage.setItem('email', item.users.email)
                        sessionStorage.setItem('accountName', item.users.userName)
                        // this.$message.info(res.message);
                        // this.$router.replace('/views/Home');
                    } else {
                        this.$message.error("此用户没有资产配置权限");
                    }
                })
                this.atableTabs = res.data.profession[0].menus
            })
        } else {
            this.atableTabs = JSON.parse(sessionStorage.getItem('tabArray')).menus

            this.activeKey = this.atableTabs[0].menuName
            this.accountName = sessionStorage.getItem('accountName')
            that.handleClick("1");
        }

        // getAction(that.url.queryICode, {pCode:that.queryParam.pCode}).then(res => {
        //     if (res.success) {
        //         that.queryICodeModel = res.result
        //     }
        // })
        // getAction(that.url.queryCustomerSacCode, {}).then(res => {
        //     if (res.success) {
        //         that.queryCustomerSacCodeModel = res.result
        //           //that.$set(that.queryParam,"pCode",that.queryCustomerSacCodeModel[0]);
        //       that.loadData();
        //     }
        // })
    },
    methods: {
        onClick() {},
        handleClick(activeKey) {
            let that = this;
            this.atableTabs.map(item => {
                if (that.activeKey === item.menuName) {
                    this.$router.replace(item.menuUrl);
                }
            })
            // if(that.activeKey=="研究报告"){
            //      this.$router.replace(that.url.ResearchReport);
            // }
            // if(that.activeKey=="宏观数据"){
            //      this.$router.replace(that.url.MacroData);
            // }
            // if(that.activeKey=="资产配置"){
            //      this.$router.replace(that.url.AssetAllocation);
            // }
            // if(that.activeKey=="FOF构建"){
            //      this.$router.replace(that.url.FOFbuild);
            // }

        },
        //退出登录
        goBack() {
            //sessionStorage.removeItem('accountName');
            sessionStorage.clear();
            localStorage.clear();
            this.$router.replace("/");
        },
    },

}
</script>
